
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>注册</title>
	<link rel="stylesheet" href="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.css" >
	<link rel="stylesheet" href="./css/me.css" >
</head>
<body>
	<br />
	<br />
	<div class="m-container-small m-padded-tb-massive" style="max-width: 30em !important;">
		<div class="ui container">
			<div class="ui middle aligned center aligned grid">
				<div class="column">
					<h2 class="ui teal image header">
					
						<div class="content">
							密码重置
						</div>
					</h2>
					<form id="app" class="ui large form">
						<div class="ui stacked segment">
							<div class="field">
							  <div class="ui left icon input">
								<i class="user icon"></i>
								<input type="password" id="oldpwd" placeholder="请输入原密码">
							  </div>
							</div>
							<div class="field">
							  <div class="ui left icon input">
								<i class="lock icon"></i>
								<input type="password" id="newpwd" placeholder="输入新密码">
                                
							  </div>
							</div>
							<div class="field">
							  <div class="ui left icon input">
								<i class="lock icon"></i>
								<input type="password" id="newpwd2" placeholder="确认密码">
							  </div>
							</div>
							<div class="field" style="display:none;" id="msgDiv">
							  <div class="ui left icon input">
                                  <span style="color: red; align-content: center;" id="msg">密码不一致</span>
							  </div>
							</div>
						
							<div onclick="updatePassword()" class="ui fluid large teal submit button">重置</div>
						</div>
				
						
				
					</form>
				
					
				</div>
			</div>

		</div>
	</div>

    <script src="js/jquery.min.js"></script>
    <script src="js/semantic.min.js"></script>
    <script src="js/axios.js"></script>
    
    <script>

		function updatePassword(){
			var oldpwd=$("#oldpwd").val();
			var newpwd=$("#newpwd").val();
			var newpwd2=$("#newpwd2").val();
			if(newpwd!=newpwd2){
				$("#msg").html("两次密码输入不一致....");
				$("#msgDiv").show();
				return false;
			}else{
				var values={};
				values.oldpwd=oldpwd;
				values.newpwd=newpwd;
				axios.post('user/updatePassword',values).then(function (res){
					var data=res.data;
					if(data.code==200){
						window.location.href="login.html";
					}else{
						$("#msg").html(data.msg);
						$("#msgDiv").show();
					}
				})
			}
		}

    	
    </script>

</body>
</html>
